package com.snnsh.kjb.lottery.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.snnsh.kjb.lottery.service.ProductService;
import com.snnsh.kjb.lottery.vo.ProductVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * packageName com.snnsh.kjb.lottery.web.controller
 *
 * @author wick
 * @version V1.0.0
 * @date 2025/5/27
 */
@RestController
@RequestMapping("/product")
public class ProductController extends BaseController{

    @Autowired
    private ProductService productService;

    @RequestMapping("/list")
    public JSONObject getProductList(){
        return success(productService.queryList(null));
    }

    @RequestMapping("/showlist")
    public JSONObject showList() {
        return showListSuccess(productService.queryList(null));
    }

    @RequestMapping("/deleteById")
    public JSONObject deleteById(Integer id) {
        productService.deleteById(id);
        return success("删除成功");
    }

    @PostMapping("/addProduct")
    public JSONObject addProduct(ProductVO product) {
        productService.addProduct(product);
        return success("添加成功");
    }

    @PostMapping("/updateProduct")
    public JSONObject updateProduct(ProductVO product) {
        productService.updateProduct(product);
        return success("更新成功");
    }
}
